﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using CookieSessionAuthorization.Models;
using CookieSessionAuthorization.Common;
using CookieSessionAuthorization.Filters;

namespace CookieSessionAuthorization.Controllers {

    [MyActionAuthrizaFilter]//添加权限过滤器
    public class HomeController : Controller {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger) {
            _logger = logger;
        }

        public IActionResult Index() {
            //从cookie获取用户信息
            CurrentUser user = HttpContext.GetCurrentUserByCookie();
            //CurrentUser user = HttpContext.GetCurrentUserBySession();
            return View(user);
        }
    }
}
